package API.File.Practise;

import java.io.File;

public class _5GetDirBytes {
    public static void main(String[] args) {
        File file = new File(".");
        System.out.println(GetDirBytes(file) / 1024f / 1024 + "MB");
    }

    public static long GetDirBytes(File file) {
        long bytes = 0;
        File[] files = file.listFiles();
        for (File f : files) {
            if (f.isDirectory()) {
                bytes += GetDirBytes(f);
            } else if (f.isFile()) {
                bytes += f.length();
            }
        }
        return bytes;
    }
}
